#pragma once

#include <QListWidget>
#include <QListWidgetItem>
#include <QMouseEvent>
#include <QMenu>
#include <QAction>
#include <QPoint>
#include <QDockWidget>

#include "datamanager.h"
#include "renderselectdialog.h"
#include "fileextensionmanager.h"

namespace PBVP {
	class MainWindow;
	class MainInterface;
	/// <summary>
	/// 
	/// </summary>
	class DataManagerView : public QListWidget {
		Q_OBJECT
	public:
		DataManagerView(MainInterface *pMainInterface, QWidget* parent = NULL);

		~DataManagerView();

	signals:
		void itemRightClicked(QListWidgetItem *item, const QPoint& point);

		void rendererChanged();

		void datanodeChanged();

	public slots:
		void updateAll();

		void deleteCurrent();

		void showPopupMenu(QListWidgetItem *item, const QPoint& pos);

		void showDataProperties();

		void changeRenderer();
		
		/// Handle the case that a data item is clicked
		
		void dataClicked(int n);
		
		/// 
		void renameDataNode();
		
		/// 
		void saveCurrent();

		///
		void hidePropertyPane();

	protected:
		virtual void mousePressEvent(QMouseEvent *e);

	private:
		MainWindow *m_pMainWindow;
		DataManager *m_pDataManager;
		FileExtensionManager *m_pFileExtensionManager;

		QMenu *popupMenu;
		QAction *itemDeleteAction;
		QAction *showPropertiesAction;
		QAction *selectRendererAction;
		QAction *renameAction;
		QAction *dataSaveAction;

		RenderSelectDialog *renderSelect;
		// position of mouse click
		QPoint m_Pos;

		// Pointer to the property dock widget in the main window
		QDockWidget *propDock;
	};
}
